/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.anism.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
 
/**
 *
 * @author tgqm5519
 */
@Entity
@Table(name = "employee")
@SequenceGenerator(name = "seq_pk_employee", sequenceName = "seq_pk_employee", allocationSize = 1)
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Employee.findAll", query = "SELECT e FROM Employee e"),
    @NamedQuery(name = "Employee.findByFirstName", query = "SELECT e FROM Employee e WHERE e.firstName = :firstName"),
    @NamedQuery(name = "Employee.findByLastName", query = "SELECT e FROM Employee e WHERE e.lastName = :lastName"),
    @NamedQuery(name = "Employee.findById", query = "SELECT e FROM Employee e WHERE e.id = :id"),
    @NamedQuery(name = "Employee.findByEmployeeId", query = "SELECT e FROM Employee e WHERE e.employeeId = :employeeId"),
    @NamedQuery(name = "Employee.findByPassword", query = "SELECT e FROM Employee e WHERE e.password = :password"),
    @NamedQuery(name = "Employee.findByDays", query = "SELECT e FROM Employee e WHERE e.days = :days")})
public class Employee implements Serializable {
    private static final long serialVersionUID = 1L;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 256)
    @Column(name = "first_name", nullable = false, length = 256)
    private String firstName;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 256)
    @Column(name = "last_name", nullable = false, length = 256)
    private String lastName;
    @Id
    @GeneratedValue(generator = "seq_pk_employee")
    @Basic(optional = false)
    @NotNull
    @Column(name = "id", nullable = false)
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 1024)
    @Column(name = "employee_id", nullable = false, length = 1024)
    private String employeeId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 256)
    @Column(name = "password", nullable = false, length = 256)
    private String password;
    @Basic(optional = false)
    @NotNull
    @Column(name = "days", nullable = false)
    private int days;
    @OneToMany(mappedBy = "validator")
    private Collection<HolidayRequest> holidayRequestCollection;
    @OneToMany(mappedBy = "owner")
    private Collection<HolidayRequest> holidayRequestCollection1;
    @OneToMany(mappedBy = "substitutes")
    private Collection<Employee> employeeCollection;
    @JoinColumn(name = "substitutes", referencedColumnName = "id")
    @ManyToOne
    private Employee substitutes;
    @OneToMany(mappedBy = "isManagedBy")
    private Collection<Employee> employeeCollection1;
    @JoinColumn(name = "is_managed_by", referencedColumnName = "id")
    @ManyToOne
    private Employee isManagedBy;

    public Employee() {
    }

    public Employee(Integer id) {
        this.id = id;
    }

    public Employee(Integer id, String firstName, String lastName, String employeeId, String password, int days) {
        this.id = id;
        this.firstName = firstName;
        this.lastName = lastName;
        this.employeeId = employeeId;
        this.password = password;
        this.days = days;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getEmployeeId() {
        return employeeId;
    }

    public void setEmployeeId(String employeeId) {
        this.employeeId = employeeId;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public int getDays() {
        return days;
    }

    public void setDays(int days) {
        this.days = days;
    }

    @XmlTransient
    public Collection<HolidayRequest> getHolidayRequestCollection() {
        return holidayRequestCollection;
    }

    public void setHolidayRequestCollection(Collection<HolidayRequest> holidayRequestCollection) {
        this.holidayRequestCollection = holidayRequestCollection;
    }

    @XmlTransient
    public Collection<HolidayRequest> getHolidayRequestCollection1() {
        return holidayRequestCollection1;
    }

    public void setHolidayRequestCollection1(Collection<HolidayRequest> holidayRequestCollection1) {
        this.holidayRequestCollection1 = holidayRequestCollection1;
    }

    @XmlTransient
    public Collection<Employee> getEmployeeCollection() {
        return employeeCollection;
    }

    public void setEmployeeCollection(Collection<Employee> employeeCollection) {
        this.employeeCollection = employeeCollection;
    }

    public Employee getSubstitutes() {
        return substitutes;
    }

    public void setSubstitutes(Employee substitutes) {
        this.substitutes = substitutes;
    }

    @XmlTransient
    public Collection<Employee> getEmployeeCollection1() {
        return employeeCollection1;
    }

    public void setEmployeeCollection1(Collection<Employee> employeeCollection1) {
        this.employeeCollection1 = employeeCollection1;
    }

    public Employee getIsManagedBy() {
        return isManagedBy;
    }

    public void setIsManagedBy(Employee isManagedBy) {
        this.isManagedBy = isManagedBy;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Employee)) {
            return false;
        }
        Employee other = (Employee) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.anism.entity.Employee[ id=" + id + " ]";
    }
    
}
